const api = require("../../utils/api");
Page({
  data: {
    PageCur: 'bills'
  },
  onLoad() {
    console.log("页面初始化");
    let that = this;
    api.get("/user/check/login").then(res=>{
      // 说明token已经失效，或者根本没有登录过，此时需要重新登录 切换到登录页
      if (res.data === 0) {
        that.setData({
          PageCur: 'mySelf'
        })
      }
    });
  },
  NavChange(e) {
    this.setData({
      PageCur: e.currentTarget.dataset.cur
    })
  },
  onShareAppMessage() {
    return {
      title: 'WOOW记账-支持多人记账的小程序',
      imageUrl: '/images/share.png',
      path: '/pages/index/index'
    }
  },
  /**
   * 跳转记账
   */
  bookKeeping() {
    console.log("点击了  记账");
    let billPage = this.selectComponent("#bill");
    if (billPage) {
      billPage.createBill();
    } else {
      // 先切换为记账页面再 弹出记账模态框
      this.setData({
        PageCur: "bills"
      })
      this.selectComponent("#bill").createBill();
    }
  }
})